package com.lei.app.entity.socket.room;

import com.lei.app.entity.base.BaseEntity;
import lombok.Data;
import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;

import java.sql.Timestamp;
import java.util.List;

/**
 * @author 郑兴泉 956607644@qq.com
 * @data 2020/4/9
 * 描述：
 */
@Data
@Table("web_socket_room")
@Comment("用户房间")
public class SocketRoom extends BaseEntity {

    @Name
    @PrevInsert(uu32 = true)
    @ColDefine(width = 32, notNull = true)
    @Comment("主键")
    private String uuid;

    @Column
    @Comment("房间名称")
    private String name;

    @Column
    @ColDefine(width = 50)
    @Comment("IP地址")
    private String sessionId;

    @Column
    @ColDefine(width = 50)
    @Comment("IP地址")
    private String httpSessionId;

    @Column
    @ColDefine(width = 255)
    @Comment("简介")
    private String note;

    @Column
    @Comment("状态")
    private Boolean sysState = false;

    @Column
    @Comment("最大人数")
    private Integer maxNumber;

    @Column
    @Comment("创建房间的所在的Ip地址")
    private String ctIp;

    @Column
    @Comment("排序字段")
    @Prev({
            @SQL(db = DB.MYSQL, value = "SELECT IFNULL(MAX(sort),0)+1 FROM web_socket_room"),
            @SQL(db = DB.ORACLE, value = "SELECT COALESCE(MAX(sort),0)+1 FROM web_socket_room")
    })
    private Integer sort;

    @ManyMany(from = "roomId", relation = "web_socket_room_user", to = "userId")
    private List<SocketRoomUser> users;


}
